package com.sugon.entity.dto;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 设备-模具故障时长详情VO
 *
 * @author YuXD
 * @since 2022-05-11
 */
@Data
public class DevMoldFaultDurationCommonVO implements Serializable {

    /**
     * 故障名称
     */
    private String name;

    /**
     * 故障开始时间
     */
    private Date startTime;

    /**
     * 故障结束时间
     */
    private Date endTime;

    /**
     * 时长
     */
    private Long duration;

    public Long getDuration() {
        if (duration != null) {
            return duration;
        }
        return DateUtil.between(this.startTime, this.endTime, DateUnit.MINUTE);
    }

}
